<!doctype html>
<html>

	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../css/mui.css" rel="stylesheet" />
		<link rel="stylesheet" href="../css/header.css">

		<style type="text/css">
			.mui-table-view-cell>a {
				height: 75px;
			}

			.mui-media-body:nth-child(1) {
				margin-top: 4%;
			}

			.mui-media-body:nth-child(2) {
				margin-top: 2%;
			}

			.mui-media-body:nth-child(3) {
				margin-top: 4%;
			}

			.mui-media-body:nth-child(4) {
				margin-top: 4%;
			}

			.mui-table-view-cell>a>img {
				margin-top: 1%;
				margin-right: 3%;
			}

			.mui-table-view-cell>a>span {
				margin-top: 3%;
				margin-right: 3%;
			}

			body {
				overflow: hidden;
			}

			body::-webkit-scrollbar {
				display: none;
			}
		</style>
	</head>


	<body>
		<header class="mui-bar mui-bar-nav">
			<h1 class="mui-title">我的</h1>
		</header>

		<div class="mui-content">
			<ul class="mui-table-view">
				<li class="mui-table-view-cell mui-media">
					<a id="link_updateImg" href="javascript:;">
						<span class="mui-icon mui-icon-arrowright mui-pull-right"></span>
						<img class="mui-media-object mui-pull-right" id="faceImage">
						<div class="mui-media-body">
							头像
						</div>
					</a>
				</li>
				<li class="mui-table-view-cell mui-media">
					<a id="link_nickname" href="javascript:;">
						<span class="mui-icon mui-icon-arrowright mui-pull-right"></span>
						<div class="mui-media-body">
							昵称
						</div>
						<p class="mui-ellipsis" id="nickname"></p>
					</a>
				</li>
				<li class="mui-table-view-cell mui-media">
					<a href="javascript:;">
						<div class="mui-media-body">
							账号
							<p class="mui-ellipsis" id="username"></p>
						</div>
					</a>
				</li>
				<li class="mui-table-view-cell mui-media">
					<a id="link_my_qrcode" href="javascript:;">
						<span class="mui-icon mui-icon-arrowright mui-pull-right"></span>
						<img class="mui-media-object mui-pull-right" src="../images/qrcode.png">
						<div class="mui-media-body">
							二维码
						</div>
					</a>
				</li>

			</ul>

			<ul class="mui-table-view" id="logout" style="margin-top: 40%;">
				<li class="mui-table-view-cell mui-media">
					<a href="javascript:;" style="text-align: center;">
						<div class="mui-media-body" style="color: red;">
							退出
						</div>
					</a>
				</li>
			</ul>

		</div>


	</body>
	<script src="../js/mui.js"></script>
	<script src="../js/app.js" type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript">
		mui.init();

		mui.plusReady(function() {
			flushUserInfo();
			
			
			//添加自定义事件，刷新头像及个人信息
			window.addEventListener("refresh", function() {
				flushUserInfo();
			});


			plus.webview.currentWebview().setStyle({
				scrollIndicator: 'none'
			});
			//获取当前窗口对象、进行刷新
			var WebView = plus.webview.currentWebview();
			WebView.addEventListener("show", function() {
				flushUserInfo();
			});

			document.getElementById("link_updateImg").addEventListener("tap", function() {
				mui.openWindow({
					id: 'wh-myface.html',
					url: 'wh-myface.html'
				});

			})
			//修改昵称
			document.getElementById("link_nickname").addEventListener("tap", function() {
				mui.openWindow({
					id: 'wh-mynickname.html',
					url: 'wh-mynickname.html'
				});

			})

			//二维码页面
			document.getElementById("link_my_qrcode").addEventListener("tap", function() {
				mui.openWindow({
					id: 'wh-my-qrcode.html',
					url: 'wh-my-qrcode.html'
				});

			})



			//退出登录
			var logoutDom = document.getElementById("logout");
			logoutDom.onclick = function() {
				app.removeUserGlobalInfo();
				mui.openWindow({
					id: 'login.html',
					url: 'login.html'
				});

			}

		});

		function flushUserInfo() {
			//刷新用户属性
			var user = app.getUserGlobalInfo();
			var faceImage = user.faceImage;
			var nickname = user.nickname;
			var username = user.username;

			var faceImageDom = document.getElementById("faceImage");
			var nicknameDom = document.getElementById("nickname");
			var usernameDom = document.getElementById("username");

			faceImageDom.src = user.faceImage.substring(0, 4) === "http" ? user.faceImage : app.imgServerUrl + user.faceImage
			// faceImageDom.src = "http://192.168.133.128/group1/M00/00/00/wKiFgGAeNtiAd7I2AAF8ph-6Rgw272_150x150.jpg";
			nicknameDom.innerText = nickname;
			usernameDom.innerText = username;
		}
	</script>

</html>
